package com.service;

import com.entity.Land;
import com.mapper.LandMapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.math.BigDecimal;
import java.util.List;

@Service
@Transactional
public class LandService {
    @Autowired
    private LandMapper landMapper;

    /**插入商品*/
    @Async
    public Integer InsertLand(Land land){
        return landMapper.InsertLand(land);
    }
    /**查询商品详情*/
    public Land LookLand(Land land){
        return landMapper.LookLand(land);
    }
    /**修改商品*/
    public Integer ChangeLand(Land land){
        return landMapper.ChangeLand(land);
    }
    /**修改商品状态*/
    public Integer ChangeCommstatus(String commid,Integer commstatus){
        return landMapper.ChangeCommstatus(commid,commstatus);
    }
    /**通过商品名分页模糊查询*/
    public List<Land> queryLandByName(Integer page,Integer count,String commname){
        return landMapper.queryLandByName(page,count,"%"+commname+"%");
    }
    /**模糊查询商品总数*/
    public Integer queryLandByNameCount(String commname){
        return landMapper.queryLandByNameCount("%"+commname+"%");
    }
    /**分页展示各类状态的商品信息*/
    public List<Land> queryAllLand(Integer page,Integer count,String userid,Integer commstatus){
        return landMapper.queryAllLand(page,count,userid,commstatus);
    }
    /**查询商品各类状态的总数*/
    public Integer queryLandCount(String userid,Integer commstatus){
        return landMapper.queryLandCount(userid,commstatus);
    }
    /**首页分类展示8条商品*/
    public List<Land> queryLandByCategory(String category){
        return landMapper.queryLandByCategory(category);
    }
    /**产品清单分类分页展示商品*/
    public List<Land> queryAllLandByCategory(Integer page,Integer count,String area,String school,String category,BigDecimal minmoney,BigDecimal maxmoney){
        return landMapper.queryAllLandByCategory(page,count,area,school,category,minmoney,maxmoney);
    }
    /**查询产品清单分类分页展示商品的总数*/
    public Integer queryAllLandByCategoryCount(String area, String school, String category, BigDecimal minmoney, BigDecimal maxmoney){
        return landMapper.queryAllLandByCategoryCount(area,school,category,minmoney,maxmoney);
    }
}
